
<?php

/*
* This script lists all members associated with the project.
* If a user is logged in, his/her name appear in green, otherwise it appears in redish/orange.
* @header pname 
*/

require_once("../functions/connect_to_database.php");
require_once("../functions/isOnline.php");

$project_name = mysql_real_escape_string($_POST['pname']);

// Get all users that are online
$users_online = isOnlineArray();

$query = ("SELECT participant,isChicken from projects where name='$project_name'");
$result = mysql_query($query);

				if(!$result)
								die(mysql_error());

				//Display participants in alphabetical order
				echo("<div id='users'>"); 
				while ($row = mysql_fetch_assoc($result)) {
					$chicken = $row['isChicken'] == "0" ? false : true;
					if (in_array($row['participant'], $users_online)) {
						//make chickens blue, pigs green. Also prepend chicken names with a #
						echo sprintf("<p class='usersOnline'><img src=".($chicken ? 'images/blue.png' : 'images/green.png')." alt='green' height='15' width='15' /><font color=".($chicken ? '#0066ff' : 'green') .">". ($chicken ? "#" : "")  .$row['participant']."</font></p>");
					}
					else{
						echo sprintf("<p class='usersOffline'><img src='images/red.png' alt='green' height='15' width='15' /><font color='#D83820'>".($chicken ? "#" : ""). $row['participant']."</font></p>");
					}
								
				}
				echo("<div>");
				
				echo ('<script type="text/javascript">
				//autoRefresh
				var users_timeout = startUserRefresh();
				</script>');

?>
